﻿namespace CRM.Business.Services
{
    using System.Collections.Generic;
    using CRM.DataAccess.DAOs;
    using CRM.DataAccess.Entities;

    public static class UserService
    {
        /// Gets or sets the user DAO.
        private static UserDAO UserDAO = new UserDAO();
        
        /// Get All User
        public static List<USER> ListAll()
        {
            return UserDAO.ListAll();
        }
        //Get User by ID
        public static USER GetUserByID(long ID)
        {
            return UserDAO.GetUserByID(ID);
        }
        //Get User by Username
        public static USER GetUserByUsername(string Username)
        {
            return UserDAO.GetUserByUsername(Username);
        }
        //Add new User
        public static int AddNewUser(USER user)
        {
            return UserDAO.AddNewUser(user);
        }
        //Change password
        public static int ChangePassword(USER user)
        {
            return UserDAO.ChangePassword(user);
        }
        //Check exist
        public static int CheckExist(string username)
        {
            return UserDAO.CheckExist(username);
        }
        //Login
        public static USER UserLogin(string username, string userhash)
        {
            return UserDAO.UserLogin(username, userhash);
        }
        //User login history
        public static void LoginHistory(USERS_LOGINS userLogin)
        {
            UserDAO.LoginHistory(userLogin);
        }
        //Get User by condition
        public static List<USER_DETAIL> GetUserByCondition(string UserName, bool? isAdmin, string primaryemail, string officephone, long? RoleID)
        {
            return UserDAO.GetUserByCondition(UserName, isAdmin, primaryemail, officephone, RoleID);
        }

        //Get User Detail by ID
        public static USER_DETAIL GetUserDetailByID(long id)
        {
            return UserDAO.GetUserDetailByID(id);
        }
        // Get User by Role ID
        public static List<USER> GetUserByRoleID(long id)
        {
            return UserDAO.GetUserByRoleID(id);
        }
        //update user
        public static int UpdateUser(USER user)
        {
            return UserDAO.UpdateUser(user);
        }
        //update user detail
        public static int UpdateUserDetail(USER_DETAIL userDe)
        {
            return UserDAO.UpdateUserDetail(userDe);
        }

        //Delete User
        public static int DeleteUser(long userID)
        {
            return UserDAO.DeleteUser(userID);
        }
    }
}
